package com.stu.mapper;

import com.stu.pojo.StuScore;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StuScoreMapper {

    /**
     * 根据学生表的id查询成绩信息
     * @param currentId
     */
    @Select("select * from stu_score where stu_id = #{currentId}")
    StuScore selectByBasicId(Long currentId);

    @Select("SELECT " +
            "(SELECT COUNT(*) + 1 FROM stu_score AS s2 " +
            "WHERE s2.stu_class = s1.stu_class AND s2.comprehensive > s1.comprehensive) AS `rank` " +
            "FROM stu_score AS s1 WHERE s1.stu_id = #{currentId};")
    Integer selectRankByBasicId(Long currentId);

    @Select("select number from class_information where class_name = #{stuClass}")
    Integer selectClassNumberByStuClass(String stuClass);

    @Select("select id from violation_information where stu_id =#{currentId}")
    Integer selectViolationByBasicID(Long currentId);
}
